package edu.cmu.vlis.datamining.TopologicalFeatures;
import java.io.*;
import java.util.*;


public class CascadeIterator {
    String[] br;
    String next;
    int ind;
    CascadeIterator(String str) {
	//try {
	    br = str.split("\n");
	    next = br[0];
     ind =1;
	//}
	//catch(IOException e) {
	//    e.printStackTrace();
//	}
    }

    int getNextSize() {
    System.out.println("in GNS");
	String[] parts = next.split(" ");
	if(parts==null) {
		   System.out.println("out null GNS");
		return 0;
	}
	else {
		   System.out.println("out not null GNS");
	return parts.length/2;
	}
    }

    boolean hasNext() {
    	   //System.out.println("in HN");
	return (next!=null);
    }

    void advanceWithoutFetch() {
    	  // System.out.println("in AWF");
	if (next!=null && ind<br.length) {
//	    try {
		next = br[ind];
		ind++;
//	    }
//	    catch(IOException e) {
//		e.printStackTrace();
//	    }
	}
	else 
		next =null;
	   //System.out.println("out  AWF " + next);
    }

    Cascade nextJustNodes() {
    //	   System.out.println("in NJN");
	Cascade casc = new Cascade(next);
	advanceWithoutFetch();
	//   System.out.println("out NJN");
	return casc;
    }
    
    Cascade next() {
    	   System.out.println("in Next");
    	if(next!=null) {
	Cascade casc = new Cascade(next);
	//try{
	if (ind==br.length)
		 next = null;
	else {
	    next = br[ind];
	    ind++;
	}
	/*}
	catch(IOException e) {
	    e.printStackTrace();
	}*/
	   System.out.println("out Next");
	return casc;
    	}
    return null;	
    }
    

}